Load (current) module for a given baseline

Hello,

 

given an open baseline, how can I load the curresponding (current) module?

        string modNam = fullName(mod)
        Module retMod = read(modNam, false)
        return retMod

or is there a better way?

 


thsturm - Fri Sep 20 04:20:01 EDT 2019

Re: Load (current) module for a given baseline
Mike.Scharnow - Fri Sep 20 07:19:18 EDT 2019

I think that's the best way

Re: Load (current) module for a given baseline
thsturm - Fri Sep 20 07:58:09 EDT 2019

For the protocol here my function (with debug output):

Module moduleFromBaseline(Module mod) {
        print "first: " fullName(mod) " [" version(mod) "] #" isBaseline(mod) "\n"
        string modNam = fullName(mod)
        Module retMod = read(modNam, false)
        print "last: " fullName(retMod) " [" version(retMod) "] #" isBaseline(retMod) "\n"
        return retMod
}

 

Re: Load (current) module for a given baseline
O.Wilkop - Fri Sep 20 08:20:15 EDT 2019

thsturm - Fri Sep 20 07:58:09 EDT 2019

For the protocol here my function (with debug output):

Module moduleFromBaseline(Module mod) {
        print "first: " fullName(mod) " [" version(mod) "] #" isBaseline(mod) "\n"
        string modNam = fullName(mod)
        Module retMod = read(modNam, false)
        print "last: " fullName(retMod) " [" version(retMod) "] #" isBaseline(retMod) "\n"
        return retMod
}

 

I prefer checking if the current version is already open before using read(). Especially when the code is run often (for example in adxl/ldxl or a trigger) it is important not to use read() too often or you will experience performance issues.

 

Module moduleFromBaseline(Module mod){
    ModName_ mn = module(mod);
    ModuleVersion mv = moduleVersion(mn) //moduleVersion of the current version
    Module mCurrent = data(mv); //check if already open
    if(null mCurrent) mCurrent = load(mv, false); //load current version in read only mode
    return mCurrent;   
}